<% layout('/layouts/default.html', {title: '考核任务信息表管理', libs: ['dataGrid','fileupload','validate']}){ %>
<style>
    .menu {
        padding: 2px;
        cursor: pointer;
        margin: 2px 1px 2px;
    }

    .options {
        position: absolute;
        display: none;
        width: 100px;
        height: 200px;
        background: #eee;
        /*overflow: auto;*/
    }

    .menu:hover .options {
        display: block;
    }
</style>
<div class="main-content">

    <div class="box box-main">
        <div class="box-header">
            <div style="float: left">
                <button class="btn btn-default btn-sm" style="font-size: 16px" onclick="js.closeCurrentTabPage()" >返回</button>
            </div>
            <#form:form id="searchForm" model="${dcSupExamSumQuotaInfo}"  action="${ctx}/quota/dcSupExamSumQuotaInfo/quotaPlayListData2" method="post" class="form-inline "
            data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
            <div style="float: right">
                <#form:hidden path="versionNumber" value="${dcSupExamSumQuotaInfo.versionNumber}" />
                <#form:hidden path="examId" value="${dcSupExamSumQuotaInfo.examId}" />
                <#form:hidden path="examYear" value="${dcSupExamSumQuotaInfo.examYear}" />
                <#form:hidden path="exameOrg" value="${dcSupExamSumQuotaInfo.exameOrg}" />
                <#form:hidden path="exameOrgName" value="${dcSupExamSumQuotaInfo.exameOrgName}" />
                <div class="form-group">
                    <label class="control-label">${text('指标类别')}：</label>
                    <div class="control-inline" style="width: 400px;">
                        <#form:select path="quotaTypes" dictType="dc_quotaType"  multiple="true"  blankOptionLabel="全  部"    class="form-control "  onchange="changeForm()" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">${text('目标内容')}：</label>
                    <div class="control-inline">
                        <#form:input path="quotaContent"  class="form-control" placeholder="请在此处输入版本名称"/>
                    </div>
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>

                    <button onclick="cz();" class="btn btn-default btn-sm">${text('重置')}</button>
                    <a href="#"  onclick="exportExamSumQuotaInfo()" class="btn btn-primary btn-sm" title="${text("导出")}">导出</a>
                </div>
            </div>
        </#form:form>
    </div>
    <div class="box-body">
        <table id="dataGrid"></table>
        <div id="dataGridPage"></div>
    </div>
</div>
</div>
<% } %>
<script>
    var dataCount;

    var flag = false;
    function changeForm(){
        flag =true
        $("#searchForm").submit();
    }

    function cz(){
        searchForm.reset();
        $('#dataGrid').dataGrid('reloadGrid');
    }

    $('dataGrid').css('margin-bottom','230px')
    // 初始化DataGrid对象
    $('#dataGrid').dataGrid({
        searchForm: $("#searchForm"),
        columnModel: [
            {header:'${text("主键")}', name:'id', hidden:true},
            {header:'${text("类别")}', name:'quotaType',width:80,
                formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('dc_quotaType')},
                        val, '${text("未知")}', true);
                }
            },
            {header:'${text("目标内容")}',  name:'quotaContent', index:'a.quota_content', width:160},
            {header:'${text("单位")}', name:'quotaUnit', index:'a.quota_unit', width:60, align:"center"},
            {header:'${text("权数")}',name:'quotaWeight', index:'a.quota_weight', width:60, align:"center",
                formatter: function(val, obj, row, act){
                    if(val == null){
                        return 0.00;
                    }else{
                        return parseFloat(val).toFixed(2);
                    }
                }
            },
            {header:'${text("本年度目标")}', name:'currentYaerGoal', index:'a.current_yaer_goal', width:65, align:"center"},
            {header:'${text("考核方式")}', name:'assessMethod', width:60, align:"center",
                formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('dc_exam_assessment')},
                        val, '${text("")}', true);
                }
            },
            {header:'${text("上年度目标任务")}',  name:'lastYaerGoal', index:'a.last_yaer_goal', width:65, align:"center"},
            {header:'${text("上年度完成情况")}', name:'lastYearComplete', index:'a.last_year_complete', width:65, align:"center"},
            {header:'${text("备注")}',name:'remarks', index:'a.remarks', width:80, align:"center",
                formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('dc_exam_remarks')},
                        val, '${text("未知")}', true);
                }},
            {header:'${text("考核评分单位")}', name:'gradeOrgName',width:120, align:"center"},
            {header:'${text("考核细则")}', name:'detailFile', width:100,align:"center",
                editable: true, edittype: "custom", editoptions: {
                    custom_element: function(val, editOptions) {
                        return js.template('fileuploadTpl', {
                            id: 'fileupload_'+editOptions.id,
                            title: '区域选择',
                            bizKey: val,
                            bizType: 'dcSupExamSumQuotaInfo_file',
                            cssClass: '',
                            readonly: true,
                            callbackFuncName: 'fileuploadCallback',
                        });
                    }
                },unformat: function(val, obj, cell){

                    return $('#fileupload_'+obj.rowId+'_fileuploadId', cell).val();
             }
            }
        ],
        // 是否显示底部合计行
        showFooter: true,
        // 是否显示行号
        showRownum: false,
        editGrid: true,
        shrinkToFit: true,
        autoGridWidth: true,
        // 加载成功后执行事件
        ajaxSuccess: function(data){
            refreshZpCount();

            dataCount =data.count
        }
    });
    function exportExamSumQuotaInfo() {
        if(dataCount){
            window.location.href ='${ctx}/quota/dcSupExamSumQuotaInfo/exportQuotaPlayListData2?versionNumber='+$('#versionNumber').val()+'&examId='+$('#examId').val()+'&examYear='+$('#examYear').val()+'&exameOrg='+$('#exameOrg').val()+'&exameOrgName='+$('#exameOrgName').val();
        }else {
            js.showMessage("当前无数据");
        }

    }
    // console.log(window.webuploader)

    function fileuploadCallback(id, act, $this, fileUploadId, fileUrl, fileName, fileUpload){

        // console.log($('.editable '))
        const num=$('.queueList .table-responsive table tbody tr td').length

        // $('.queueList .table-responsive table tbody tr td:eq(2)').remove()
        if (num>=1){
            for (let index = 0; index < num+1; index++) {

                $('.queueList .table-responsive table tbody tr:eq('+index+') td:eq(0)').addClass('none')
                $('.queueList .table-responsive table tbody tr:eq('+index+') td:eq(1)').addClass('none')
                $('.queueList .table-responsive table tbody tr:eq('+index+') td:eq(2)').addClass('none')
                $('.queueList .table-responsive table tbody tr:eq('+index+') td:eq(3)').addClass('none')
            }

        }

    }

    $(document).ready(function(){

    });
    function refreshZpCount(){
        // let addRemovedata = $('#dataGrid').dataGrid('getRowData');
        // let addRemoveQuotaWeight=0.0;
        // for (let i = 0; i < addRemovedata.length; i++) {
        //     addRemoveQuotaWeight=accAdd(parseFloat(addRemovedata[i].quotaWeight||0),addRemoveQuotaWeight);
        // }
        $('#dataGrid').dataGrid("footerData", "set", {
            "quotaUnit" : "<center><span>汇总：</span></center>",
            "quotaWeight" : "<span>&nbsp;"+'${number}'+" &nbsp;</span>分"
        }, false);
    }



    function accAdd(arg1,arg2){
        var r1,r2,m;
        try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
        try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
        m=Math.pow(10,Math.max(r1,r2))
        return (arg1*m+arg2*m)/m
    }

    function accSub(arg1,arg2){
        var r1,r2,m,n;
        try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
        try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
        m=Math.pow(10,Math.max(r1,r2));
        //last modify by deeka
        //动态控制精度长度
        n=(r1>=r2)?r1:r2;
        return ((arg1*m-arg2*m)/m).toFixed(n);
    }
</script>
<style>
.btncancel{
    display: unset;
}
    .ui-jqgrid .ui-jqgrid-btable{
        margin-bottom: 170px;
    }
    .pp{
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .dd{
        /*padding: 4% 15%;*/
        border: 1px solid #0079fe;
        color: #0079fe;
    }
    .options{
        width: 136.34px;
        /*display: block;*/
        height: 170px;
        background-color: white;
        box-shadow: 1px 14px 20px 2px #e8e8e8;
        /*top: 8.3%;*/
        right: 4.7%;
    }
    .options div{
        text-align: center;
        /*padding: 5px 5px;*/

    }
    .options div:hover{
        background-color: rgba(24, 144, 255,1);

    }

    .options div:hover a{
        color: #eeeeee;

    }

    .menu:hover .options{
        animation: anim .4s ;
    }
.none{
    display: none!important;
}

    @keyframes anim {
        0%{
            height: 0px;
        }
        100%{
            height: 170px;
        }
    }


</style>
<script id="fileuploadTpl" type="text/template">//<!--<div>
<#form:fileupload id="{{d.id}}" bizKey="{{d.bizKey}}" bizType="{{d.bizType}}" uploadType="all"
	class="{{d.cssClass}}" maxUploadNum="1"   isMini="true" preview="true"  readonly="{{d.readonly}}"/>
</div>//-->

</script>

<script>
    // console.log($('td'))
</script>